<!--
 * @Descripttion: 弹窗扩展组件
 * @version: 2.0
 * @Author: sakuya
 * @Date: 2021年8月27日08:51:52
 * @LastEditors: sakuya
 * @LastEditTime: 2022年5月14日15:13:41
-->

<template>
	<div class="ex-dialog" ref="scDialog">
	<el-dialog ref="dialog" v-model="dialogVisible" :width="width" :fullscreen="isFullscreen"
	:style="'margin-top:'+top+'px;margin-bottom:20px;'"
	class="dialogselect" :close-on-click-modal="closeOnClickModal" v-bind="$attrs" :destroy-on-close="true" :show-close="false" :draggable="true">
	<template #header>
		<div class="assetheader">
			<div style="float: left;width: 100%">
			<div class="assetheaderleft">{{title}}</div>
			<div class="assetheaderright assetheaderrightclose" @click="close">
				×
			</div>
			</div>
		</div>
	</template>

		<template #default>
			<div :style="contentHeight?'height:'+contentHeight+'px;overflow-y: auto;padding: 0 15px;':''">

				<slot name="default"></slot>
			</div>
		</template>
		<template #footer v-if="footershow==='block'">
			<slot name="footer"></slot>
		</template>
	</el-dialog>
	</div>
</template>

<script>
	export default {
    name: "exDialog",
		props: {
			modelValue: { type: Boolean, default: false },
			title: { type: String, default: "" },
			showClose: { type: Boolean, default: true },
			showFullscreen: { type: Boolean, default: true },
			closeOnClickModal: { type: Boolean, default: false },
			width:{ type: Number||String, default: 1300 },
			loading: { type: Boolean, default: false },
			footershow: { type: String, default: "block" },
			contentHeight: { type: Number, default: null },
			top:{ type: Number||String, default: 20 },
		},
		data() {
			return {
				dialogVisible: false,
				isFullscreen: false
			}
		},
		watch:{
			modelValue(){
				this.dialogVisible = this.modelValue
				if(this.dialogVisible){
					this.isFullscreen = false
				}
			}
		},
		mounted() {
			this.dialogVisible = this.modelValue
		},
		methods: {
			//关闭
			close(){
				this.dialogVisible = false
			}
		}
	}
</script>

<style scoped>
	.ex-dialog__headerbtn {position: absolute;top: var(--el-dialog-padding-primary);right: var(--el-dialog-padding-primary);}
	.ex-dialog__headerbtn button {padding: 0;background: transparent;border: none;outline: none;cursor: pointer;font-size: var(--el-message-close-size,16px);margin-left: 15px;color: var(--el-color-info);}
	.ex-dialog__headerbtn button:hover .el-dialog__close {color: var(--el-color-primary);}
	.ex-dialog:deep(.el-dialog).is-fullscreen {display: flex;flex-direction: column;top:0px !important;left:0px !important;}
	.ex-dialog:deep(.el-dialog).is-fullscreen .el-dialog__header {}
	.ex-dialog:deep(.el-dialog).is-fullscreen .el-dialog__body {flex:1;overflow: auto;}
	.ex-dialog:deep(.el-dialog).is-fullscreen .el-dialog__footer {padding-bottom: 10px;border-top: 1px solid var(--el-border-color-base);}


	.assetheader{
  width: 100%;background-color: #f8f8f8;height: 44px;line-height: 44px;
  border-bottom: 1px solid #F0F0F0;
  font-size: 14px;
}
.assetheaderleft{
  float: left;
  margin-left: 10px;
  font-size: 14px;
  color: #626262;

    font-weight: 400;
}
.assetheaderright{
  float: right;cursor: pointer;
  margin-right: 5px;
}

.assetheaderrightclose{
  position: absolute;

    font-weight: 400;
    font-size: 1.5em;
    color: rgba(0, 0, 0, 0.6);
    padding-left: 10px;
    padding-right: 10px;
    cursor: pointer;
    transform: translateZ(36px);
    text-align: center;
    box-shadow: rgb(136, 136, 136) 0px 0px 2px inset;
    z-index: 2;
    user-select: none;
    height: 25px;
    line-height: 25px;
    right: 2px !important;
    top: 5px !important;
    text-decoration: none;
    border-radius: 5px;
    background: rgb(255, 255, 255);
    transition: all 0.05s ease 0s;

}
.assetheaderrightclose:hover{
  top: 6px !important;
    right: 1px !important;
    box-shadow: rgb(136, 136, 136) 0px 0px 3px inset;

}

</style>
